
import { Message } from 'element-ui';
export const  isMobile = function() {
    let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
  return flag;
}
export const isEn = function(){
  return (localStorage.getItem('locale') || 'zh') === 'en'
}
export const escapeHtml = function(str) {
  if (!str) return str
  var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
  return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
}
//时间戳10位
export const formatDate = function (time) {//时间戳转日期
  let date = new Date(parseInt(time) * 1000);
  let y = date.getFullYear();
  let MM = date.getMonth() + 1;
  MM = MM < 10 ? ('0' + MM) : MM;
  let d = date.getDate();
  d = d < 10 ? ('0' + d) : d;
  return y + '-' + MM + '-' + d;
  // return y + '-' + MM + '-' + d;
}
export const toastErrMessage = (text) => {
  Message.error(text);
}
export const isPhone = (phone) => {
  var myreg=/^1[3-9]\d{9}$/;
  if (!myreg.test(phone)) {
     return true
  } else {
     return false
  }
}
